<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>HTML5地理位置定位</title>
</head>
<body>
    <script type="text/javascript">
    var tip = document.getElementById("tip")
    var lon = document.getElementById("lon")//经度
    var lat = document.getElementById("lat")//纬度
    var accuracy = document.getElementById("accuracy")//纬度
      window.onload=function(){
        if(navigator.geolocation){
          navigator.geolocation.getCurrentPosition(updataposition)//获取用户当前位置
        }else{
          tip.innerHTML="您的浏览器版本过低"
        }
      }
      function updataposition(data){
        console.log(data.coords);
        lon.innerHTML="纬度"+data.coords.logitude;
        lat.innerHTML="经度"+data.coords.latitude;
        latitude.innerHTML="精准度"+data.coords.latitude+"米";
        
      }

    </script>
    <div id="tip"></div>
    <div id="lon"></div>
    <div id="lat"></div>
    <div id="accuracy"></div>

</body>
</html>